package com.ifdom.objecttype.atomicinteger;

/**
 * 并发问题验证
 * Integer 有时正常，有时不正常
 * @Author ifredomvip@gmail.com
 * @Date 2022/9/30 15:19
 * @Version 1.0.0
 * @Description
 **/
public class AtomicRun implements Runnable {

    private static int count = 0;

    @Override
    public void run() {
        for (int i = 0; i < 10000; i++) {
            count++;
        }
    }

    public static void main(String[] args) throws InterruptedException {
        AtomicRun task1 = new AtomicRun();
        Thread thread1 = new Thread(task1);
        Thread thread2 = new Thread(task1);

        thread1.start();
        thread2.start();

        Thread.sleep(3000);
        System.out.println(count);

        task1 = null;

    }
}
